<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    /*   let arr1 = [1, 2, 3, 4, 54, 56, 53, 345];
  
      let arr2 = arr1.slice(0, 5);
      console.log(arr2);
  
      // 删除arr2里面最后一条
  
      // arr2.pop();
      arr2[4] = 100;
  
      console.log(arr2);
  
      console.log(arr1); */

    let goods = [
      { id: 1, name: '香蕉1' },
      { id: 2, name: '香蕉2' },
      { id: 3, name: '香蕉3' },
      { id: 4, name: '香蕉4' },
      { id: 5, name: '香蕉5' },
      { id: 6, name: '香蕉6' },
    ]

    /*  let arr1 = goods.slice(0, 5)
     console.log(arr1); // [指针，指针，指针，指针，指针，指针，]
     arr1[0].name = '苹果'
 
     console.log(goods);
     console.log(goods[0].name); // '苹果'
     goods[1].name = '梨子' */

    /* let user = [1, 2, 3, 4]
    let arr2 = user.concat(goods)
    console.log(arr2);

    arr2[4].name = "aaa"
    console.log(goods);
 */

    let obj1 = { a: 1, b: 123 }
    let s = { title: 'hhaha', content: 'abc', children: [1, 2, 34] }
    let t = Object.assign(obj1, s)
    console.log(t); // t === obj1 ,完全相等的
    console.log(obj1);
    console.log(s);

    let newObj = { ...s }  // 解构运算符，只能做浅拷贝

    console.log(newObj);

    // s.title = "饿了么"
    // obj1.a = "hhhh"

    s.children.push("jjjj")

    // object的属性的值，是引用类型，在assign()处理时，做的时浅拷贝。





  </script>
</body>

</html>